<?php
/* 
 * This class demonstrates how to connect to our database and query some data,
 * it also shows how to use the GET request(I'll get into this in more details in another demo)
 * don't forget to supply the forum id in the GET request
 */
$forumId = $_GET['id'];

// I have a feeling you'll forget to supply the forum id in the GET request anyway
if ($forumId == '') {
    $forumId = '1';
}

// this is also my email password, if you steal I'll break your neck, just kidding el password 3a 7sabak
$con = mysql_connect("127.0.0.1","root","runrun");
if (!$con) {
    die('Failed to connect to MySQL server; Error: ' . mysql_error());
}
$selected = mysql_select_db("messageboardot_db",$con);

$query = "select".
        " ID, THREAD_NAME, USER_ID, FORUM_ID, FLAG, CREATION_DATE, LAST_POST_DATE" .
        " from" .
        " THREADS" .
        " where" . 
        " FORUM_ID = " . $forumId;

$result = mysql_query($query);

// Please note that the column names are case sensitive!
while($row = mysql_fetch_assoc($result)) {
    echo "Thread id: " . $row['ID'] . "<br />";
    echo "Thread Name: " . $row['THREAD_NAME'] . "<br />";
    echo "<br />";
}

mysql_free_result($result);
mysql_close($con);
?>
